AmigaSoc UK
Configuring NetBSD

Once you have installed NetBSD on your Amiga you will still need to configure some aspects of the system to suit your needs. Listed below are a few changes you may wish to make to your NetBSD installation. Please note that you must be logged in as "root" in order to make the changes. If you have the man distribution installed you can type man command for more information about that command. i.e. man man will give you information about the man command itself.

Set a root password
The user "root" has the power to make any changes to your NetBSD installation. It is therefore wise to set a password so that no-one else can log in as root and hack you system.
To change the root password first log in as root. You will not be asked for a password as one has not been set yet. Now use the passwd command to set a password.

> passwd
Changing local password for root
New password:
Retype new password:

You will be asked to type in the password twice to make sure you have not mistyped it. The password you type in will not be displayed on the screen. You should remember your root password as without it you will be unable to administer your NetBSD system.

Mount /local filesystem
If you created a /local partition during the installation process you may be wondering where it is. So far it is just a blank space on the disk drive. For NetBSD to be able to use it you must make a filesystem on it and mount it. First use the disklabel command to find which partition /local is on. If you hard disk is sd0 then you would use the following command.

> disklabel sd0
      size   offset  fstype  [fsize  bsize  cpg]
a    62400  1035320  4.2BSD    1024  8192    0    # (Cyl. 1991-2110)
b   290680  1097720    swap                       # (Cyl. 2111-2669)
c  2069600        0  unused       0     0         # (Cyl. 0-3979)
d  1034280     1040    ADOS                       # (Cyl. 2-1990)
e   274040  1388400  4.2BSD    1024  8192    0    # (Cyl. 2670-3196)
f   407160  1662440  4.2BSD    1024  8192    0    # (Cyl. 3197-3979)


Compare the output of disklabel against the output of the df -k command to see which partitions are already mounted or check the list of start and end cylinders if you created one during the NetBSD install process.
> df -k 
Filesystem  1k-Blocks   Used   Avail Capacity  Mounted On
/dev/sd0a       30031  10578   17951    37%      /
/dev/sd0e      132251  79028   46610    63%      /usr	

Use the newfs command to create a unix filesystem on the correct partition. The output produced will depened on the size of your /local partition.

> newfs /dev/sd0f
newfs: /dev/sd0f: not a character-special device
/dev/sd0f:	407160 sectors in 783 cylinders of 5 tracks, 104 sectors
	198.8MB in 49 cyl groups (16 c/g, 4.06MB/g, 1024 i/g)
super-block backups (for fsck -b #) at:
 32, 8464, 16896, 25328, 33760, 42192, 50624, 59056,
 66592, 75024, 83456, 91888, 100320, 108752, 117184, 125616,
 133152, 141584, 150016, 158448, 166880, 175312, 183744, 192176,
 199712, 208144, 216576, 225008, 233440, 241872, 250304, 258736,
 266272, 274704, 283136, 291568, 300000, 308432, 316864, 325296,
 332832, 341264, 349696, 358128, 366560, 374992, 383424, 391856,
 399392,

Next you must create a mountpoint for your new filesystem. This is a directory upon which the filesystem is mounted.

> mkdir /local

Mount the new filesystem on /local using the mount command.

> mount /dev/sd0f /local

A df -k will now show that you have three filesystems mounted.

> df -k 
Filesystem  1k-Blocks   Used   Avail Capacity  Mounted On
/dev/sd0a       30031  10578   17951    37%      /
/dev/sd0e      132251  79028   46610    63%      /usr	
/dev/sd0f      196507  00012  196495    01%      /local	
If you wish to mount the /local filesystem every time you boot NetBSD you must edit the file /etc/fstab. First make a copy of it in case you make a mistake whilst editing.

> cp /etc/fstab /etc/fstab.old

Now use vi to edit /etc/fstab. You must add an extra entry, similar to that for /usr for the /local filesystem.

> vi /etc/fstab
/dev/sd0a       /       ffs     rw      1       1
/dev/sd0e       /usr    ffs     rw      1       2
/dev/sd0f       /local  ffs     rw      1       2

Once you have made the changes use the key combination

<esq> w q >enter<

to save the changes and exit vi. If you make a mistake during editing use the key combination

<esq> q ! >enter<

to exit without saving the changes.

Warning: you are strongly advised to read the section using vi before using the vipw command. For more information about the format of the /etc/fstab file use the command man fstab

Adding A New User
So far you only have a root user account on your NetBSD installation. However the root account should only be used for system administration. For day to day use you should create yourself (and any other users) an individual user account. Each user will have their own login name and password, and their own area for saving files known as a "home directory".
To create a new user account you can use the vipw command to edit the /etc/passwd file.
For each new user you must add an extra line to the file. The default /etc/passwd file looks similar to the one shown below.
root:#######:0:0::Superuser:/root:/bin/csh 
toor:*:0:0::Borne-again Superuser:/root: 
daemon:*:1:31::The Devil Himself:/root: 
operator:*:2:20::System &:/usr/gues/operator:/bin/csh 
bin:*:3:7::Binaries Commands and Source,,,:/:/dev/null 
games:*:7:13::Games pseudo User:/usr/games: 
uucp:*:66:1::Unix-to-Unix copy:/var/spool/uucppublic:/usr/libexec/uucico 
nobody:*:32767:9999::Unprivileged User:/nonexistent:/dev/null 
ingres:*:267:74::& Group:/usr/inges:/bin/csh 
falken:*:32766:31::Prof Stephen &:/usr/games:/usr/bin/wargames
Each line in the file corresponds to one user and contains the following information sperated by colons (:)
  • User Name - This is the name the user logs in as, it must be unique.
  • Password - NetBSD encrypts each password before it stores it in the /etc/passwd file. You should not attempt to change or add anything to the entry in this field. Instead use the passwd command to set or change a users password.
  • UID - This is the User ID. It is used by NetBSD to indicate who files are owned by. It must also be unique.
  • GID (Group ID) - Each user must belong to a group. If you have many users on your system you may wish to split them into seperate groups to make administration easier. See Adding A New Group for more information about groups and GID's.
  • Class - Unused by NetBSD, should be left blank.
  • Comment - This can be used to add additional information about the user
  • Home Directory - This tells NetBSD the path to the users home directory. Home directory's are usually named after the user in order to identify them easily and reside in /export/home. Thus a user called "user1" would have a home directory of /export/home/user1.
  • Shell - This determins which shell the user starts with every time they log in. A basic NetBSD installation only has csh available.

    To create a new user, with the log in name "user1" who belonged to the group "staff", had a home directory /export/home/user1 and used the csh as their default shell you would add the following line.

    user1:*:13:20::My First User:/export/home/user1:/bin/csh

    If you make a mistake when editing the file you can exit and start again without saving any changes by using the key combination

    esc : q ! <enter>

    When you have made all the required changes save and exit using the key combination

    esc : w q <enter>

    Warning: you are strongly advised to read the section using vi before using the vipw command.

    Once you have created the user account details you must ensure that the users home directory exists.

    > cd /export/home

    If /export/home does not yet exists on your machine you must create it with the following command

    > mkdir -p /export/home
    > chmod 755 /export/home
    > cd /export/home


    Now you can create the users home directory and change it's access permissions so that the user has complete control over it and it's contents.

    > mkdir user1
    > chown user1 user1
    > chgrp staff user1


    Note: If you wish a user to be able to su to root they must be a member of the group "wheel". This can be achieved by making "wheel" their primary group in the /etc/passwd file or by adding them to the list of members of the group wheel in the /etc/group file. See Adding A New Group for details of how to do this.

    Adding A New Group
    Groups can be used to define users roles and allow users with similar roles to easily exchange data with one another. Each group must have a unique name and ID. You can also specify a list of users who belong to that group. The group definitions are stored in the file /etc/group. To find out the numeric group ID's available on your machine use the more command to view the contents of /etc/group.

    > more /etc/group
    wheel:*:0:root
    daemon:*:1:daemon
    kmem:*:2:root
    sys:*:3:root
    tty:*:4:root
    operator:*:5:
    bin:*:7:
    news:*:8:
    usrc:*:9:
    games:*:13:
    staff:*:20:root
    guest:*:31:root
    nobody:*:39:
    utmp:*:45:
    ingres:*:47:ingres
    dialer:*:117:
    nogroup:*:32766:

    Each line corresponds to a group and consists of the following fields seperated by colons (:).
  • Groupname - The name of the group. It is not allowed to name two groups the same, however a group may share the same name as a user.
  • Password - This field should contain a * indicating a locked password field.
  • GID - Group I.D. This is the numerical I.D of the group. Each group must have a unique GID.
  • User list - This lists the usernames of the members of that group. A user may be a member of more than one group. If an entry for a user does not appear in /etc/group then their group is determined by the entry in the /etc/passwd file.

    To create a new group called sysadmin you would add the following line to the /etc/group file using vi.

    sysadmin:*:21:

    Note: remember to make a copy of /etc/group before you edit it!

    > cp /etc/group /etc/group.old
    > vi /etc/group

    If you wanted to create the sysadmin group with 3 users, Ben, Chris, and Nick you would add the following line instead.

    sysadmin:*:21:ben,chris,nick

    Note: If you wish a user to be able to su to root they must be a member of the group "wheel".

    Changing the reboot command
    The reboot command supplied with NetBSD reboots the machine back into AmigaDOS. In order to reboot NetBSD without the need to reload AmigaDOS we must create a new reboot command. Firstly we will copy the old reboot command so we can still reboot into AmigaDOS should we require to do so.

    > cp /bin/reboot /bin/reboot.amiga

    Now create the new reboot command.

    echo "cp /netbsd /dev/reload" > /bin/reboot

    You can now use the command reboot to reboot NetBSD and reboot.amiga to reboot into AmigaDOS.

    Automatically Setting up the Environment on Login
    NetBSD provides a mechanism for running commands when a user logs into a machine. This is most commonly used for setting environment variables such as the search path. NetBSD looks for a file in the users home directory to execute on login. The name of the file depends upon which shell you are using. C shell (csh) users will need a .cshrc file in their home directory, most other shell users will require a file called .profile. For more information about the contents of .profile please see article 4, shells and shell scripting.
    The .cshrc contains a list of commands to be executed by NetBSD. Any command can be put into this file. Below is a .cshrc file that sets the search path, some common aliases and the prompt. This can be modified to suit your own needs. Remember that NetBSD hides files that begin with a dot, use the command ls -la to see all files including those beginning with a dot.
    alias mail Mail
    set history=1000
    set path=(/sbin /usr/sbin /bin /usr/bin /usr/local/X11R6.1/bin /usr/local/bin)
    
    # directory stuff: cdpath/cd/back
    set cdpath=(/sys /usr/src/{bin,sbin,usr.{bin,sbin},pgrm,lib,libexec,share,contrib,local,devel,games,old,})
    
    setenv BLOCKSIZE 1k
    
    alias   cd      'set old=$cwd; chdir \!*'
    alias   h       history
    alias   j       jobs -l
    alias   ll      ls -l
    alias   back    'set back=$old; set old=$cwd; cd $back; unset back; dirs'
    
    alias   z       suspend
    alias   x       exit
    alias   pd      pushd
    alias   pd2     pushd +2
    alias   pd3     pushd +3
    alias   pd4     pushd +4
    alias   tset    'set noglob histchars=""; eval `\tset -s \!*`; unset noglob histchars'
    
    if ($?prompt) then
            set prompt="`hostname -s`# "
    endif

    To enable you to run X Windows and the applications on this months CD you should make sure you set the path in your .cshrc file to be the same as the one above.